package pv3d.cameras
{
	import core.MainManager;
	
	import flash.display.StageQuality;
	
	import memory.MemoryRecovery;
	
	import org.papervision3d.cameras.Camera3D;
	
	import view.pv3d.CameraRotationControler;
	import view.pv3d.event.CamereaControlerEvent;

	public class RotateableFreeCamera3D extends Camera3D
	{
		private var controller:CameraRotationControler;
		public function RotateableFreeCamera3D(tween_speed:Number=0.2,rotate_speed:Number=0.3)
		{
			super(2, 100);
			controller=new CameraRotationControler(MainManager.getInstance().stage,this,true,tween_speed,rotate_speed);
			controller.addEventListener(CamereaControlerEvent.UPDATE,on_update);
			controller.addEventListener(CamereaControlerEvent.UPDATED,on_updated);
		}
		//镜头开始旋转
		private function on_update(e:CamereaControlerEvent):void
		{
			MainManager.getInstance().stage.quality=StageQuality.LOW;
		}
		//镜头停止旋转
		private function on_updated(e:CamereaControlerEvent):void
		{
			MainManager.getInstance().stage.quality=StageQuality.HIGH;
		}
		/**
		 * 内存回收
		 */ 
		override public function dispose():void
		{
			super.dispose();
			MemoryRecovery.getInstance().gcFun(controller,CamereaControlerEvent.UPDATE,on_update);
			MemoryRecovery.getInstance().gcFun(controller,CamereaControlerEvent.UPDATED,on_updated);
			if(controller!=null) controller.dispose();
			controller=null;
		}
	}
}